using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace DataAccessLayer
{
    public class DAO_User_Solution_Item
    {
        public static bool Insert(Object tmp)
        {
            USER_SOLUTION_ITEM obj = (USER_SOLUTION_ITEM)tmp;
            bool result = false;
            List<SqlParameter> _list = new List<SqlParameter>();
            _list.Add(new SqlParameter("@_TABLE__PK", obj._TABLE__PK));
            _list.Add(new SqlParameter("@_TABLE__PK2", obj._TABLE__PK2));
            _list.Add(new SqlParameter("@TEST_QUESTION_ITEM_ID", obj.TEST_QUESTION_ITEM_ID));
            _list.Add(new SqlParameter("@USER_SOLUTION_ID", obj.USER_SOLUTION_ID));
            _list.Add(new SqlParameter("@USER_SOLUTION_ITEM_COMMENT", obj.USER_SOLUTION_ITEM_COMMENT));
            _list.Add(new SqlParameter("@USER_SOLUTION_ITEM_ID", obj.USER_SOLUTION_ITEM_ID));
            _list.Add(new SqlParameter("@USER_SOLUTION_ITEM_ORDER", obj.USER_SOLUTION_ITEM_ORDER));
            _list.Add(new SqlParameter("@USER_SOLUTION_ITEM_VALUE", obj.USER_SOLUTION_ITEM_VALUE));
            

            int n = clsDataAccessHelper.ExecNonQuery("sp_user_solution_item_insert", _list);
            if (n == 1)
                result = true;
            return result;
        }

        public static bool Update(Object tmp)
        {
            USER_SOLUTION_ITEM obj = (USER_SOLUTION_ITEM)tmp;
            bool result = false;
            List<SqlParameter> _list = new List<SqlParameter>();
            _list.Add(new SqlParameter("@_TABLE__PK", obj._TABLE__PK));
            _list.Add(new SqlParameter("@_TABLE__PK2", obj._TABLE__PK2));
            _list.Add(new SqlParameter("@TEST_QUESTION_ITEM_ID", obj.TEST_QUESTION_ITEM_ID));
            _list.Add(new SqlParameter("@USER_SOLUTION_ID", obj.USER_SOLUTION_ID));
            _list.Add(new SqlParameter("@USER_SOLUTION_ITEM_COMMENT", obj.USER_SOLUTION_ITEM_COMMENT));
            _list.Add(new SqlParameter("@USER_SOLUTION_ITEM_ID", obj.USER_SOLUTION_ITEM_ID));
            _list.Add(new SqlParameter("@USER_SOLUTION_ITEM_ORDER", obj.USER_SOLUTION_ITEM_ORDER));
            _list.Add(new SqlParameter("@USER_SOLUTION_ITEM_VALUE", obj.USER_SOLUTION_ITEM_VALUE));
            
            int n = clsDataAccessHelper.ExecNonQuery("sp_user_solution_item_update", _list);
            if (n == 1)
                result = true;
            return result;
        }

        public static bool Delete(Object tmp)
        {
            USER_SOLUTION_ITEM obj = (USER_SOLUTION_ITEM)tmp;
            bool result = false;
            List<SqlParameter> _list = new List<SqlParameter>();
            _list.Add(new SqlParameter("@_TABLE__PK", obj._TABLE__PK));
            _list.Add(new SqlParameter("@_TABLE__PK2", obj._TABLE__PK2));
            _list.Add(new SqlParameter("@TEST_QUESTION_ITEM_ID", obj.TEST_QUESTION_ITEM_ID));
            _list.Add(new SqlParameter("@USER_SOLUTION_ID", obj.USER_SOLUTION_ID));
            _list.Add(new SqlParameter("@USER_SOLUTION_ITEM_COMMENT", obj.USER_SOLUTION_ITEM_COMMENT));
            _list.Add(new SqlParameter("@USER_SOLUTION_ITEM_ID", obj.USER_SOLUTION_ITEM_ID));
            _list.Add(new SqlParameter("@USER_SOLUTION_ITEM_ORDER", obj.USER_SOLUTION_ITEM_ORDER));
            _list.Add(new SqlParameter("@USER_SOLUTION_ITEM_VALUE", obj.USER_SOLUTION_ITEM_VALUE));
            
            int n = clsDataAccessHelper.ExecNonQuery("sp_user_solution_item_delete", _list);
            if (n == 1)
                result = true;
            return result;
        }

        public static List<USER_SOLUTION_ITEM> LoadAll()
        {
            List<USER_SOLUTION_ITEM> _list = new List<USER_SOLUTION_ITEM>();
            //call stored getlist here
            return _list;
        }
    }
}
